import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:hbtrans_flutter/enroll/school.dart';
import 'package:hbtrans_flutter/enroll/toPay.dart';
import 'package:hbtrans_flutter/login/improve.dart';
import 'package:hbtrans_flutter/login/login.dart';
import 'package:hbtrans_flutter/main/detail/aboutus.dart';
import 'package:hbtrans_flutter/main/detail/feedback.dart';
import 'package:hbtrans_flutter/main/first/articledetail.dart';
import 'package:hbtrans_flutter/main/webview.dart';
import 'package:hbtrans_flutter/manager/host.dart';
import 'package:hbtrans_flutter/manager/listpages.dart';
import 'package:hbtrans_flutter/manager/login.dart';
import 'package:hbtrans_flutter/manager/msg_manager.dart';
import 'package:hbtrans_flutter/mine/order/OrderDetail.dart';
import 'package:hbtrans_flutter/mine/order/SignOrder.dart';
import 'package:hbtrans_flutter/mine/order/modifyOrder.dart';
import 'package:hbtrans_flutter/mine/order/myOrder.dart';
import 'package:hbtrans_flutter/mine/set/personalSet.dart';
import 'package:hbtrans_flutter/safer/page.dart';
import 'package:hbtrans_flutter/safer/search.dart';
import 'package:hbtrans_flutter/tester/page.dart';
import 'package:hbtrans_flutter/tester/search.dart';

import 'area/detail.dart';
import 'area/page.dart';
import 'area/search.dart';
import 'car/detail.dart';
import 'car/page.dart';
import 'car/search.dart';
import 'classpage/classdetail.dart';
import 'classpage/daily.dart';
import 'classpage/login.dart';
import 'classpage/rate.dart';
import 'classpage/videolearn.dart';
import 'company/detail.dart';
import 'company/page.dart';
import 'company/search.dart';
import 'enroll/carenroll.dart';
import 'enroll/sign.dart';
import 'enroll/signinfo.dart';
import 'enroll/teacherinfo.dart';
import 'main/mainpage.dart';
import 'main.dart';
import 'myijkplayer.dart';
import 'safer/detail.dart';
import 'teacher/detail.dart';
import 'teacher/page.dart';
import 'teacher/search.dart';
import 'tester/detail.dart';

class Routes {
  static Router router;
  static String rootPage = '/';
  static String login = '/login';
  static String mainPage = '/mainPage';
  static String articleDetail = '/articleDetail';
  static String listPage = '/listPage';
  static String msgManager = '/msgManager';
  static String pageHost = '/pageHost';
  static String comSearch = '/comSearch';
  static String areaSearch = '/areaSearch';
  static String areaDetail = '/areaDetail';
  static String comDetail = '/comDetail';
  static String sign = '/sign';
  static String signInfo = '/signInfo';
  static String teacherInfo = '/teacherInfo';
  static String school = '/school';
  static String carDetail = '/carDetail';
  static String comPage = '/comPage';
  static String areaPage = '/areaPage';
  static String teacherPage = '/teacherPage';
  static String carPage = '/carPage';
  static String saferPage = '/saferPage';
  static String testerPage = '/testerPage';
  static String webView = '/webView';
  static String classLogin = '/classLogin';
  static String classDetail = '/classDetail';
  static String periodDaily = '/periodDaily';
  static String rate = '/rate';
  static String carEnroll = '/carEnroll';
  static String teacherSearch = '/teacherSearch';
  static String teacherDetail = '/teacherDetail';
  static String testerDetail = '/testerDetail';
  static String saferDetail = '/saferDetail';
  static String myIjkPlayer = '/myIjkPlayer';
  static String videoLearn = '/videoLearn';
  static String feedBack = '/feedBack';
  static String aboutUs = '/aboutUs';
  static String saferSearch = '/saferSearch';
  static String testerSearch = '/TesterSearch';
  static String carSearch = '/carSearch';
  static String register = '/register';
  static String personalSet = '/personalSet';
  static String myOrder = '/myOrder';
  static String orderDetail = '/orderDetail';
  static String pay = '/pay';
  static String modifyOrder = '/modifyOrder';
  static String signOrder = '/signOrder';
  static String improve = '/improve';

  static var listHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String type = params['type']?.first;
    String titleIndex = params['titleIndex']?.first;
    String page = params['page']?.first;
    return ListPage(type: type, titleIndex: titleIndex, page: page);
  });

  static var loginHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String pageIndex = params['pageIndex']?.first;
    return Login(
      pageIndex: pageIndex,
    );
  });

  static var registerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        return Register();
      });

  static var improveHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        return ImproveInformation();
      });


  static var myOrderHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        return MyOrder();
      });

  static var signOrderHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        return SignOrder();
      });



  static var orderDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        return OrderDetail();
      });

  static var personalSetHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        return PersonalSet();
      });

  static var myIjkPlayerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String url = params['url']?.first;
    return MyIjkPlayer(
      url: url,
    );
  });

  static var msgManagerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String pageIndex = params['pageIndex']?.first;
    return MessageManager(
      pageIndex: pageIndex,
    );
  });

  static var pageHostHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String hostTitle = params['hostTitle']?.first;
    String pageType = params['pageType']?.first;
    return PageHost(
      hostTitle: hostTitle,
      pageType: pageType,
    );
  });

  static var articleDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String articleId = params['articleId']?.first;
    return ArticleDetail(
      articleId: articleId,
    );
  });

  static var comSearchHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ComSearch();
  });
  static var areaSearchHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return AreaSearch();
  });

  static var teacherearchHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return TeacherSearch();
  });

  static var saferSearchHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return SaferSearch();
  });

  static var testerSearchHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return TesterSearch();
  });

  static var carSearchHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return CarSearch();
  });

  static var mainPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return MainPage();
  });
  static var areaDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String id = params['id']?.first;
    return AreaDetail(id: id);
  });

  static var classLoginHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ClassLogin();
  });
  static var rateHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Rate();
  });

  static var carEnrollHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return CarEnroll();
  });

  static var signHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String phone = params['phone']?.first;
    String address = params['address']?.first;
    String name = params['name']?.first;
    String inscode = params['inscode']?.first;
    return Sign(
      phone: phone,
      address: address,
      name: name,
      inscode: inscode,
    );
  });
  static var signInfoHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return SignInfo();
  });
  static var teacherInfoHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return TeacherInfo();
  });

  static var schoolHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return School();
  });

  static var classDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String content = params['content']?.first;
    return ClassDetail(content: content);
  });

  static var comDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String inscode = params['inscode']?.first;
    return DetailPage(inscode: inscode);
  });

  static var carDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String carnum = params['carnum']?.first;
    return CarDetail(carnum: carnum);
  });

  static var teacherDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String coachnum = params['coachnum']?.first;
    return TeacherDetail(coachnum: coachnum);
  });

  static var testerDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String examnum = params['examnum']?.first;
    return TesterDetail(examnum: examnum);
  });

  static var saferDetailHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String secunum = params['secunum']?.first;
    return SaferDetail(secunum: secunum);
  });

  static var webViewHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String title = params['title']?.first;
    String url = params['url']?.first;
    return WebView(title: title, url: url);
  });

  static var periodDailyHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String stunum = params['stunum']?.first;
    String subject = params['subject']?.first;
    String needtime = params['needtime']?.first;
    String lastinstancetime = params['lastinstancetime']?.first;
    return PeriodDaily(
        stunum: stunum,
        subject: subject,
        needtime: needtime,
        lastinstancetime: lastinstancetime);
  });

  static var comPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String status = params['status']?.first;
    String level = params['level']?.first;
    String organizId = params['organizId']?.first;
    String sonOrganizId = params['sonOrganizId']?.first;
    return ComPage(
      status: status,
      level: level,
      organizId: organizId,
      sonOrganizId: sonOrganizId,
    );
  });

  static var areaPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String status = params['status']?.first;
    String organizId = params['organizId']?.first;
    String sonOrganizId = params['sonOrganizId']?.first;
    return AreaPage(
      status: status,
      organizId: organizId,
      sonOrganizId: sonOrganizId,
    );
  });

  static var teacherPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String status = params['status']?.first;
    String organizId = params['organizId']?.first;
    String sonOrganizId = params['sonOrganizId']?.first;
    return TeacherPage(
      status: status,
      organizId: organizId,
      sonOrganizId: sonOrganizId,
    );
  });

  static var carPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String status = params['status']?.first;
    String organizId = params['organizId']?.first;
    String sonOrganizId = params['sonOrganizId']?.first;
    String perdritype = params['perdritype']?.first;
    String assign = params['assign']?.first;
    return CarPage(
      status: status,
      organizId: organizId,
      sonOrganizId: sonOrganizId,
      perdritype: perdritype,
      assignId: assign,
    );
  });

  static var saferPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String status = params['status']?.first;
    String organizId = params['organizId']?.first;
    String sonOrganizId = params['sonOrganizId']?.first;
    return SaferPage(
      status: status,
      organizId: organizId,
      sonOrganizId: sonOrganizId,
    );
  });

  static var testerPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String status = params['status']?.first;
    String organizId = params['organizId']?.first;
    String sonOrganizId = params['sonOrganizId']?.first;
    return TesterPage(
      status: status,
      organizId: organizId,
      sonOrganizId: sonOrganizId,
    );
  });

  static var videoLearnHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return VideoLearn();
  });
  static var payHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        String orderId = params['orderId']?.first;
        return Pay(
          orderId:orderId,
        );
      });
  static var modifyOrderHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        String orderId = params['orderId']?.first;
        return ModifyOrder(
          orderId:orderId,
        );
      });

  static var feedBackHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return FeedBack();
  });

  static var aboutUsHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return AboutUs();
  });

  static void configureRoutes(Router router) {
    router.define(rootPage,
        handler: Handler(handlerFunc: (context, params) => PageRoot()));

    router.define(listPage, handler: listHandler);
    router.define(login, handler: loginHandler);
    router.define(mainPage, handler: mainPageHandler);
    router.define(articleDetail, handler: articleDetailHandler);

    router.define(msgManager, handler: msgManagerHandler);
    router.define(pageHost, handler: pageHostHandler);
    router.define(comSearch, handler: comSearchHandler);
    router.define(areaSearch, handler: areaSearchHandler);
    router.define(areaDetail, handler: areaDetailHandler);
    router.define(comDetail, handler: comDetailHandler);

    router.define(comPage, handler: comPageHandler);
    router.define(areaPage, handler: areaPageHandler);
    router.define(teacherPage, handler: teacherPageHandler);
    router.define(carPage, handler: carPageHandler);
    router.define(saferPage, handler: saferPageHandler);
    router.define(testerPage, handler: testerPageHandler);
    router.define(webView, handler: webViewHandler);
    router.define(classLogin, handler: classLoginHandler);
    router.define(classDetail, handler: classDetailHandler);
    router.define(periodDaily, handler: periodDailyHandler);
    router.define(rate, handler: rateHandler);
    router.define(carEnroll, handler: carEnrollHandler);
    router.define(sign, handler: signHandler);
    router.define(signInfo, handler: signInfoHandler);
    router.define(teacherInfo, handler: teacherInfoHandler);
    router.define(school, handler: schoolHandler);
    router.define(teacherSearch, handler: teacherearchHandler);
    router.define(teacherDetail, handler: teacherDetailHandler);
    router.define(testerDetail, handler: testerDetailHandler);
    router.define(saferDetail, handler: saferDetailHandler);
    router.define(carDetail, handler: carDetailHandler);
    router.define(myIjkPlayer, handler: myIjkPlayerHandler);
    router.define(videoLearn, handler: videoLearnHandler);
    router.define(feedBack, handler: feedBackHandler);
    router.define(aboutUs, handler: aboutUsHandler);
    router.define(saferSearch, handler: saferSearchHandler);
    router.define(testerSearch, handler: testerSearchHandler);
    router.define(carSearch, handler: carSearchHandler);
    router.define(register, handler: registerHandler);
    router.define(personalSet, handler:personalSetHandler);
    router.define(myOrder, handler:myOrderHandler);
    router.define(orderDetail, handler:orderDetailHandler);
    router.define(pay, handler:payHandler);
    router.define(modifyOrder, handler:modifyOrderHandler);
    router.define(signOrder, handler:signOrderHandler);
    router.define(improve, handler:improveHandler);
    Routes.router = router;
  }
}
